package com.ruoyi.dl.controller.wechat;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.dl.domain.DlProblem;
import com.ruoyi.dl.service.IDlProblemService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 问题反馈Controller
 *
 * @author ruoyi
 * @date 2020-12-28
 */
@Controller
@RequestMapping("/wechat/dl/problem")
public class WeChatDlProblemController extends BaseController {

    @Autowired
    private IDlProblemService dlProblemService;

    /**
     * 查询问题反馈列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(DlProblem dlProblem) {
        startPage();
        List<DlProblem> list = dlProblemService.newSelectDlProblemList(dlProblem);
        return getDataTable(list);
    }

    /**
     * 导出问题反馈列表
     */
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(DlProblem dlProblem) {
        List<DlProblem> list = dlProblemService.selectDlProblemList(dlProblem);
        ExcelUtil<DlProblem> util = new ExcelUtil<DlProblem>(DlProblem.class);
        return util.exportExcel(list, "problem");
    }


    /**
     * 新增保存问题反馈
     */
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(DlProblem dlProblem) {
        return toAjax(dlProblemService.insertDlProblem(dlProblem));
    }


    /**
     * 修改保存问题反馈
     */
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(DlProblem dlProblem) {
        return toAjax(dlProblemService.updateDlProblem(dlProblem));
    }

    /**
     * 删除问题反馈
     */
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(dlProblemService.deleteDlProblemByIds(ids));
    }
}
